//
//  DKFileTaskManager.h
//  Whistle
//
//  Created by ZhangAo on 29/01/2018.
//  Copyright © 2018 BookSir. All rights reserved.
//

#import "DKBaseManager.h"
#import "DKFileBaseTask.h"

@protocol DKFileTaskManagerObserver <NSObject>

@optional

// 文件下载的进度
- (void)fileTaskManagerDownloadDidUpdate:(NSString *)key progress:(NSNumber *)progress;

// 带有文件大小的文件下载的进度
- (void)fileTaskManagerDownloadDidUpdate:(NSString *)key progress:(NSNumber *)progress fileSize:(NSNumber *)fileSize;

// 文件下载完成
- (void)fileTaskManagerDownloadFinish:(NSString *)key error:(NSError *)error;

// 文件上传的进度
- (void)fileTaskManagerUploadDidUpdate:(NSString *)key progress:(NSNumber *)progress;

// 带有文件大小的文件上传的进度
- (void)fileTaskManagerUploadDidUpdate:(NSString *)key progress:(NSNumber *)progress fileSize:(NSNumber *)fileSize;

// 文件上传完成
- (void)fileTaskManagerUploadFinish:(NSString *)key error:(NSError *)error;

@end

#define GetFileTaskManager()        ([DKFileTaskManager sharedInstance])

@interface DKFileTaskManager : DKBaseManager

- (void)startFileTask:(DKFileBaseTask *)task
        progressBlock:(void (^)(CGFloat percent))progressBlock
        completeBlock:(void (^)(NSError *error))completeBlock;

- (BOOL)isDownloadingForKey:(NSString *)key;

- (BOOL)isUploadingForKey:(NSString *)key;

- (void)cancelTask:(DKFileBaseTask *)task;

- (DKFileBaseTask *)taskForKey:(NSString *)key;

@end

